package com.heking.widgetlib;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.OrientationHelper;
import androidx.recyclerview.widget.RecyclerView;

import android.os.Bundle;
import android.view.View;

import com.zhoug.common.adapters.recycler.BaseRecyclerViewAdapter;
import com.zhoug.common.adapters.recycler.dividers.ListItemDecoration;
import com.zhoug.common.router.ZRouter;
import com.zhoug.widget.adapter.TextItemAdapter;

import java.util.Arrays;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private MainActivity mSelf;
    private RecyclerView mRecyclerView;
    private TextItemAdapter mTextItemAdapter;
    private List<String> mData = Arrays.asList("水平跑马灯", "圆角图片", "圆角按钮", "默认空界面", "LoadView",
            "AlphaView","GroupItemView","底部导航菜单BottomNavigationView");

    private BaseRecyclerViewAdapter.OnItemClickListener mOnItemClickListener = new BaseRecyclerViewAdapter.OnItemClickListener() {
        @Override
        public void onItemClick(BaseRecyclerViewAdapter adapter, View view, int position) {
            switch (position) {
                case 0:
                    ZRouter.navigation(mSelf, HMarqueeActivity.class);
                    break;
                case 1:
                    ZRouter.navigation(mSelf, RoundImageActivity.class);
                    break;
                case 2:
                    ZRouter.navigation(mSelf, RoundButtonActivity.class);
                    break;
                case 3:
                    ZRouter.navigation(mSelf, EmptyViewActivity.class);
                    break;
                case 4:
                    ZRouter.navigation(mSelf, LoadViewActivity.class);
                    break;
                case 5:
                    ZRouter.navigation(mSelf, AlphaViewActivity.class);
                    break;
                case 6:
                    ZRouter.navigation(mSelf, GroupItemViewActivity.class);
                    break;
                case 7:
                    ZRouter.navigation(mSelf, BottomNavigationActivity.class);
                    break;
            }
        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mSelf = this;
        findViews();
        initRecyclerView();
    }

    private void findViews() {
        mRecyclerView = findViewById(R.id.recyclerView);
    }

    private void initRecyclerView() {
        mTextItemAdapter = new TextItemAdapter();
        mTextItemAdapter.setData(mData);
        mTextItemAdapter.setOnItemClickListener(mOnItemClickListener);
        mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
        mRecyclerView.addItemDecoration(new ListItemDecoration(this, OrientationHelper.VERTICAL));
        mRecyclerView.setAdapter(mTextItemAdapter);
    }

}